﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;

namespace MEsE.NET.Dialogit
{
    class RoundConverter: IValueConverter 
    {
        public object Convert(object value, Type targettype, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value != null)
            {
                double? val = value as double?;

                if (val != null)
                    return (int)val;
                else
                    return -1;
            }

            return -1;
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            string val = value.ToString();

            byte valByte = 0;

            byte.TryParse(val, out valByte);
            return valByte;
        } 
    }
}
